﻿using System;

namespace 命令模式
{
    class Program
    {
        static void Main(string[] args)
        {
            var che = new 车();
            var deng = new 灯();
            var cheCmd = new CheCommand(che);
            var dengCmd = new DengCommand(deng);
            var control = new 遥控器();
            control.cmmand = cheCmd;
            control.Run();



            Console.ReadKey();
        }
    }



    public interface ICommand
    {
        void Excute();
    }

    public class 遥控器
    {
        public ICommand cmmand { get; set; }
        public void Run()
        {
            cmmand.Excute();
        }

    }

    public class 灯
    {
        public void On()
        {
            Console.WriteLine("开.....");
        }
        public void Off()
        {
            Console.WriteLine("关.....");
        }
    }
    public class DengCommand : ICommand
    {
        private readonly 灯 _deng;
        public DengCommand(灯 deng)
        {
            _deng = deng;
        }

        public void Excute()
        {
            _deng.On();
        }
    }




    public class 车
    {
        public void Up()
        {
            Console.WriteLine("车门开了.....");
        }

        public void Down()
        {
            Console.WriteLine("车门关闭了....");
        }

    }

    public class CheCommand : ICommand
    {
        private readonly 车 _che;
        public CheCommand(车 che)
        {
            _che = che;
        }
        public void Excute()
        {
            _che.Up();
        }
    }


    




}
